home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / tool / helper / src / graphic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  28.5 KB  |  1,231 lines

  1. #include    <stdio.h>
  2. #include    <stdlib.h>
  3. #include    <stdarg.h>
  4. #include    <string.h>
  5. #include    <time.h>
  6. #include    <egb.h>
  7. #include    <mos.h>
  8. #include    <snd.h>
  9. #include    <msdos.cf>
  10. #include    "graphic.h"
  11. #include    "coldef.h"
  12. #include    "dir.h"
  13.  
  14. #define    TRUE    1
  15. #define    FALSE    0
  16. #define    ERR    (-1)
  17.  
  18.     int    tick_timer = 0;
  19.     int    now_mos = 0;
  20.     int    screen_flg = FALSE;
  21.     char    work[EgbWorkSize];
  22.     char    mwork[MosWorkSize];
  23.     char    swork[16384];
  24.  
  25. static    void    (*timer_addr)() = (void (*)())0;
  26. static    char    *eup_buf = NULL;
  27. static struct _PLT {
  28.     char    b,r,g;
  29.     } plt_tbl[16]={
  30.     { 0,0,0 },    { 14,12,13 },
  31.     { 6,13,4 },    { 7,5,6 },
  32.     { 6,4,5 },    { 5,3,4 },
  33.     { 4,2,3 },    { 3,1,2 },
  34.     { 9,7,8 },    { 0,0,0 },
  35.     { 8,2,12 },    { 9,7,8 },
  36.     { 8,6,7 },    { 7,5,6 },
  37.     { 10,8,9 },    { 15,13,14 }
  38.     };
  39.  
  40. static char    mosptn[][66]={
  41.     { 2, 16,
  42.     0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 
  43.     0x30, 0x00, 0x58, 0x00, 0x3C, 0x00, 0x5E, 0x00, 
  44.     0x2F, 0x00, 0x5F, 0x80, 0x2E, 0x00, 0x7C, 0x00, 
  45.     0x66, 0x00, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 
  46.     0x7F, 0xFF, 0x3F, 0xFF, 0x5F, 0xFF, 0x6F, 0xFF, 
  47.     0x37, 0xFF, 0x5B, 0xFF, 0x3D, 0xFF, 0x5E, 0xFF, 
  48.     0x2F, 0x7F, 0x5F, 0xBF, 0x2E, 0x7F, 0x7D, 0xFF, 
  49.     0x66, 0xFF, 0x16, 0xFF, 0x7B, 0x7F, 0xF8, 0x7F },
  50.     { 2, 16,
  51.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x40, 
  52.     0x05, 0x40, 0x05, 0x50, 0x15, 0x50, 0x15, 0x50, 
  53.     0x1F, 0xF0, 0x1F, 0xF0, 0x1F, 0xF0, 0x0F, 0xF0, 
  54.     0x07, 0xE0, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00,
  55.     0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0xBF, 0xF5, 0x5F, 
  56.     0xF5, 0x4F, 0xE5, 0x57, 0xD5, 0x57, 0xD5, 0x57, 
  57.     0xDF, 0xF7, 0xDF, 0xF7, 0xDF, 0xF7, 0xEF, 0xF7, 
  58.     0xF7, 0xEF, 0xFB, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF },
  59.     { 2, 16,
  60.     0x00, 0x00, 0x2F, 0xF4, 0x2F, 0xF4, 0x2F, 0xF4, 
  61.     0x37, 0xEC, 0x39, 0x9C, 0x3C, 0x3C, 0x3E, 0x7C, 
  62.     0x3E, 0x7C, 0x3D, 0xBC, 0x3B, 0xDC, 0x36, 0x6C, 
  63.     0x2C, 0x34, 0x28, 0x14, 0x20, 0x04, 0x00, 0x00,
  64.     0x00, 0x00, 0xAF, 0xF5, 0xAF, 0xF5, 0xAF, 0xF5, 
  65.     0xB7, 0xED, 0xB9, 0x9D, 0xBC, 0x3D, 0xBE, 0x7D, 
  66.     0xBE, 0x7D, 0xBD, 0xBD, 0xBB, 0xDD, 0xB6, 0x6D, 
  67.     0xAC, 0x35, 0xA8, 0x15, 0xA0, 0x05, 0x00, 0x00 },
  68.     { 2, 16,
  69.     0x03, 0x00, 0x03, 0x80, 0x02, 0xC0, 0x02, 0x40, 
  70.     0x02, 0x40, 0x02, 0x00, 0x0E, 0x00, 0x1E, 0x00, 
  71.     0x1E, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x6A, 0xE0, 
  72.     0x4A, 0xA0, 0x6A, 0xE0, 0x4A, 0x80, 0x6E, 0x80,
  73.     0xFB, 0x7F, 0xFB, 0xBF, 0xFA, 0xDF, 0xFA, 0x5F, 
  74.     0xFA, 0x5F, 0xE2, 0x9F, 0xCE, 0xFF, 0xDE, 0xFF, 
  75.     0xDE, 0xFF, 0xCD, 0xFF, 0xE1, 0xFF, 0xFF, 0xFF, 
  76.     0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  77.     { 2, 16,
  78.     0x00, 0x00, 0x07, 0x00, 0x08, 0x80, 0x0A, 0x40, 
  79.     0x01, 0x40, 0x05, 0x40, 0x02, 0x40, 0x08, 0x40, 
  80.     0x04, 0x80, 0x07, 0x00, 0x00, 0x00, 0x75, 0x60, 
  81.     0x47, 0x50, 0x77, 0x50, 0x17, 0x50, 0x75, 0x60,
  82.     0xF0, 0x7F, 0xF7, 0x7F, 0xE8, 0xBF, 0xEA, 0x5F, 
  83.     0xE1, 0x5F, 0xE5, 0x5F, 0xE2, 0x5F, 0xE8, 0x5F, 
  84.     0xF4, 0xBF, 0xF7, 0x7F, 0xF0, 0x7F, 0xFF, 0xFF, 
  85.     0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
  86.  
  87. void    DSP_mos(int no)
  88. {
  89.     now_mos = no;
  90.     MOS_type(1,0,0,mosptn[no]);
  91. }
  92. BLOCK    *DSP_push_vram(int x1,int y1,int x2,int y2)
  93. {
  94.     register BLOCK *para;
  95.     int     n;
  96.  
  97.     n = ((x2 - x1 + 8) / 8 * 4) * (y2 - y1 + 1) + 16;    /* 4 Bit Pix */
  98.  
  99.     if ( (para = (BLOCK *)malloc(n)) == NULL )
  100.     return NULL;
  101.  
  102.     para->ptn = para->img;
  103.     para->sel = getds();
  104.     para->x1 = x1;
  105.     para->y1 = y1;
  106.     para->x2 = x2;
  107.     para->y2 = y2;
  108.     EGB_getBlock(work,(char *)para);
  109.     return para;
  110. }
  111. void    DSP_pop_vram(BLOCK *para)
  112. {
  113.     if ( para == NULL )
  114.     return;
  115.     EGB_putBlock(work,0,(char *)para);
  116.     free(para);
  117. }
  118. void    DSP_putptn(char *ptn,int x1,int y1,int x2,int y2,
  119.             int fc,int bc,int md)
  120. {
  121.     BLOCK para;
  122.  
  123.     para.ptn = ptn;
  124.     para.sel = getds();
  125.     para.x1 = x1;
  126.     para.y1 = y1;
  127.     para.x2 = x2;
  128.     para.y2 = y2;
  129.     EGB_color(work,0,fc);
  130.     EGB_color(work,1,bc);
  131.     EGB_writeMode(work,md);
  132.     EGB_putBlockColor(work,0,(char *)(¶));
  133.     EGB_writeMode(work,0);
  134. }
  135. void    DSP_strimg(char *ptn, int x, int y, int fc, int bc, int mod)
  136. {
  137.     BLOCK para;
  138.  
  139.     para.ptn = ptn + 4;
  140.     para.sel = getds();
  141.     para.x1 = x;
  142.     para.y1 = y;
  143.     para.x2 = x + (unsigned char)(ptn[0]) + (unsigned char)(ptn[1]) * 256 - 1;
  144.     para.y2 = y + (unsigned char)(ptn[2]) + (unsigned char)(ptn[3]) * 256 - 1;
  145.     EGB_color(work,0,fc);
  146.     EGB_color(work,1,bc);
  147.     EGB_writeMode(work,mod);
  148.     EGB_putBlockColor(work,0,(char *)(¶));
  149.     EGB_writeMode(work,0);
  150. }
  151. void    DSP_strcls(char *ptn, int x, int y, int bc, int mod)
  152. {
  153.     struct {
  154.     short int    x1,y1,x2,y2;
  155.     } line;
  156.  
  157.     line.x1 = x;
  158.     line.y1 = y;
  159.     line.x2 = x + (unsigned char)(ptn[0]) + (unsigned char)(ptn[1]) * 256 - 1;
  160.     line.y2 = y + (unsigned char)(ptn[2]) + (unsigned char)(ptn[3]) * 256 - 1;
  161.  
  162.     EGB_paintMode(work,0x022);
  163.     EGB_color(work,0,bc);
  164.     EGB_color(work,2,bc);
  165.     EGB_writeMode(work,mod);
  166.     EGB_rectangle(work,(char *)&line);
  167.     EGB_writeMode(work,0);
  168. }
  169. void    DSP_msg(char *str,int x,int y,int font,int fc,int bc,int mod)
  170. {
  171.     struct {
  172.     short int    x,y;
  173.     short int    len;
  174.     char        str[120];
  175.     } msg;
  176.  
  177.     msg.x = x;
  178.     msg.y = y + 15;
  179.     msg.len = strlen(str);
  180.     strcpy(msg.str,str);
  181.  
  182.     EGB_textSpace(work,0);
  183.     EGB_fontStyle(work,font);
  184.     EGB_color(work,0,fc);
  185.     EGB_color(work,1,bc);
  186.     EGB_writeMode(work,mod);
  187.     EGB_sjisString(work,(char *)&msg);
  188. }
  189. void    DSP_connect(int x1,int y1,int x2,int y2,int col,int mod)
  190. {
  191.     struct {
  192.     short int    point;
  193.     short int    x1,y1;
  194.     short int    x2,y2;
  195.     } poly;
  196.  
  197.     poly.point = 2;
  198.     poly.x1 = x1;
  199.     poly.x2 = x2;
  200.     poly.x1 = y1;
  201.     poly.y2 = y2;
  202.  
  203.     EGB_paintMode(work,0x002);
  204.     EGB_color(work,0,col);
  205.     EGB_writeMode(work,mod);
  206.     EGB_connect(work,(char *)&poly);
  207.     EGB_writeMode(work,0);
  208. }
  209. void    DSP_line(int x1,int y1,int x2,int y2,int col,int mod)
  210. {
  211.     struct {
  212.     short int    x1,y1,x2,y2;
  213.     } line;
  214.  
  215.     line.x1 = x1;
  216.     line.y1 = y1;
  217.     line.x2 = x2;
  218.     line.y2 = y2;
  219.     EGB_paintMode(work,0x002);
  220.     EGB_color(work,0,col);
  221.     EGB_writeMode(work,mod);
  222.     EGB_rectangle(work,(char *)&line);
  223.     EGB_writeMode(work,0);
  224. }
  225. void    DSP_box(int x1,int y1,int x2,int y2,int col,int mod)
  226. {
  227.     struct {
  228.     short int    x1,y1,x2,y2;
  229.     } line;
  230.  
  231.     line.x1 = x1;
  232.     line.y1 = y1;
  233.     line.x2 = x2;
  234.     line.y2 = y2;
  235.     EGB_paintMode(work,0x022);
  236.     EGB_color(work,0,col);
  237.     EGB_color(work,2,col);
  238.     EGB_writeMode(work,mod);
  239.     EGB_rectangle(work,(char *)&line);
  240.     EGB_writeMode(work,0);
  241. }
  242. void    DSP_rbox(int x1,int y1,int x2,int y2,int lin,int col,int mod)
  243. {
  244.     struct {
  245.     short int    x1,y1,x2,y2;
  246.     } line;
  247.  
  248.     line.x1 = x1;
  249.     line.y1 = y1;
  250.     line.x2 = x2;
  251.     line.y2 = y2;
  252.     EGB_paintMode(work,0x022);
  253.     EGB_color(work,0,lin);
  254.     EGB_color(work,2,col);
  255.     EGB_writeMode(work,mod);
  256.     EGB_rectangle(work,(char *)&line);
  257.     EGB_writeMode(work,0);
  258. }
  259. void    DSP_wbox(int x1,int y1,int x2,int y2,int lin,int col,int mod)
  260. {
  261.     struct {
  262.     short int    point;
  263.     short int    trx2,try2;
  264.     short int    trx3,try3;
  265.     short int    brx1,bry1;
  266.     short int    brx2,bry2;
  267.     short int    brx3,bry3;
  268.     short int    blx1,bly1;
  269.     short int    blx2,bly2;
  270.     short int    blx3,bly3;
  271.     short int    tlx1,tly1;
  272.     short int    tlx2,tly2;
  273.     short int    tlx3,tly3;
  274.     short int    trx1,try1;
  275.     } poly;
  276.  
  277.     poly.point = 12;
  278.  
  279.     poly.tlx1 = x1+0; poly.tlx2 = x1+1; poly.tlx3 = x1+2;
  280.     poly.tly1 = y1+2; poly.tly2 = y1+1; poly.tly3 = y1+0;
  281.  
  282.     poly.trx1 = x2-2; poly.trx2 = x2-1; poly.trx3 = x2+0;
  283.     poly.try1 = y1+0; poly.try2 = y1+1; poly.try3 = y1+2;
  284.  
  285.     poly.brx1 = x2+0; poly.brx2 = x2-1; poly.brx3 = x2-2;
  286.     poly.bry1 = y2-2; poly.bry2 = y2-1; poly.bry3 = y2+0;
  287.  
  288.     poly.blx1 = x1+2; poly.blx2 = x1+1; poly.blx3 = x1+0;
  289.     poly.bly1 = y2-0; poly.bly2 = y2-1; poly.bly3 = y2-2;
  290.  
  291.     EGB_paintMode(work,0x022);
  292.     EGB_color(work,0,lin);
  293.     EGB_color(work,2,col);
  294.     EGB_writeMode(work,mod);
  295.     EGB_polygon(work,(char *)&poly);
  296.  
  297.     poly.point = 7;
  298.     EGB_paintMode(work,0x002);
  299.     EGB_color(work,0,lin ^ 0x08);
  300.     EGB_connect(work,(char *)&poly);
  301.  
  302.     EGB_writeMode(work,0);
  303. }
  304. void    DSP_vsync(void)
  305. {
  306.     while ( (peek(0xFDA0) & 1) != 0 );
  307.     while ( (peek(0xFDA0) & 1) == 0 );
  308. }
  309. void    DSP_opbox(int x1,int y1,int x2,int y2)
  310. {
  311.     int     i;
  312.     int     ix1,iy1,ix2,iy2;
  313.     int     sx1,sy1,sx2,sy2;
  314.  
  315.     ix1 = (x1 + x2) / 2 - 8;
  316.     ix2 = ix1 + 15;
  317.     iy1 = (y1 + y2) / 2 - 8;
  318.     iy2 = iy1 + 15;
  319.  
  320.     sx1 = (ix1 - x1) / 10;
  321.     sy1 = (iy1 - y1) / 10;
  322.     sx2 = (x2 - ix2) / 10;
  323.     sy2 = (y2 - iy2) / 10;
  324.  
  325.     for ( i = 10 ; i >= 0 ; i-- ) {
  326.     DSP_line(ix1,iy1,ix2,iy2,15,4);
  327.     DSP_vsync();
  328.     DSP_line(ix1,iy1,ix2,iy2,15,4);
  329.     ix1 -= sx1;
  330.     iy1 -= sy1;
  331.     ix2 += sx2;
  332.     iy2 += sy2;
  333.     }
  334. }
  335. void    DSP_clbox(int x1,int y1,int x2,int y2)
  336. {
  337.     int     i;
  338.     int     ix1,iy1,ix2,iy2;
  339.     int     sx1,sy1,sx2,sy2;
  340.  
  341.     ix1 = (x1 + x2) / 2 - 8;
  342.     ix2 = ix1 + 15;
  343.     iy1 = (y1 + y2) / 2 - 8;
  344.     iy2 = iy1 + 15;
  345.  
  346.     sx1 = (ix1 - x1) / 10;
  347.     sy1 = (iy1 - y1) / 10;
  348.     sx2 = (x2 - ix2) / 10;
  349.     sy2 = (y2 - iy2) / 10;
  350.  
  351.     for ( i = 10 ; i >= 0 ; i-- ) {
  352.     DSP_line(x1,y1,x2,y2,15,4);
  353.     DSP_vsync();
  354.     DSP_line(x1,y1,x2,y2,15,4);
  355.     x1 += sx1;
  356.     y1 += sy1;
  357.     x2 -= sx2;
  358.     y2 -= sy2;
  359.     }
  360. }
  361. void    DSP_palette(void)
  362. {
  363.     struct {
  364.     int    cnt;
  365.     int    col;
  366.     char    b,r,g;
  367.     char    btm;
  368.     } para;
  369.     int     i;
  370.  
  371.     for ( i = 0 ; i < 16 ; i++ ) {
  372.     para.cnt = 1;
  373.     para.col = i;
  374.     para.b = plt_tbl[i].b * 16;
  375.     para.r = plt_tbl[i].r * 16;
  376.     para.g = plt_tbl[i].g * 16;
  377.     para.btm = 0;
  378.         EGB_palette(work,0,(char *)¶);
  379.     }
  380. }
  381. void    TICK_count(void)
  382. {
  383.     tick_timer++;
  384.     timer_addr();
  385. }
  386. void    DSP_init(void)
  387. {
  388.     SND_init(swork);
  389.     SND_rs_midi_init();
  390.     SND_eup_init(swork);
  391.     SND_elevol_mute(0xB3);
  392.  
  393.     timer_addr = SND_int_timer_b_get();
  394.     SND_int_timer_b_set(TICK_count);
  395. /**************
  396.     SND_fm_timer_a_set(1,900);
  397. ***************/
  398.  
  399.     EGB_init(work,EgbWorkSize);
  400.     EGB_resolution(work,0,3);
  401.     EGB_resolution(work,1,3);
  402.     EGB_displayPage(work,0,3);
  403.     EGB_writePage(work,1);
  404.     DSP_palette();
  405.     EGB_writePage(work,0);
  406.     DSP_palette();
  407.  
  408.     MOS_start(mwork,MosWorkSize);
  409.     MOS_resolution(0,3);
  410.     MOS_resolution(1,3);
  411.     MOS_writePage(0);
  412.     MOS_horizon(0,632);
  413.     MOS_vertical(0,470);
  414.     DSP_mos(MOS_NOMAL);
  415.     MOS_disp(TRUE);
  416.     ctblset(15, SCRN_COL);
  417. }
  418. void    DSP_end(void)
  419. {
  420.     MOS_end();
  421.     SND_elevol_mute(0x00);
  422.     SND_eup_end();
  423.     SND_rs_midi_end();
  424.     SND_end();
  425. }
  426. void    gprintf(int x,int y,int c,int b,char *form,...)
  427. {
  428.     va_list arg;
  429.     char    tmp[256];
  430.  
  431.     va_start(arg,form);
  432.     vsprintf((char *)tmp,form,arg);
  433.     wrtstr(tmp,0,x,y,c,b,16);
  434.     va_end(arg);
  435. }
  436. void    gputs(int x,int y,int c,int b,char *str)
  437. {
  438.     wrtstr(str,0,x,y,c,b,16);
  439. }
  440. void    DSP_offset(int page,int x,int y)
  441. {
  442.     vram_offset((page == 0 ? 17:21),x/8+y*128);
  443. }
  444. void    DSP_clear(int no)
  445. {
  446.     EGB_writePage(work,no);
  447.     EGB_color(work,1,0);
  448.     EGB_clearScreen(work);
  449.     EGB_writePage(work,0);
  450. }
  451. void    DSP_page(int no)
  452. {
  453.     EGB_writePage(work,no);
  454. }
  455.  
  456. #include    "sysicon.c"
  457.  
  458. int    ESR_setupInfo(char *out_buf);
  459.  
  460. char    drv_tbl[]={
  461.     IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,    /* A-H */
  462.     IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,    /* I-P */
  463.     IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,IS_NON,    /* Q-X */
  464.     IS_NON,IS_NON };                        /* Y-Z */
  465.  
  466. void    ICON_init(void)
  467. {
  468.     int     i;
  469.     char    tmp[256];
  470.  
  471.     ESR_setupInfo((char *)tmp);
  472.  
  473.     for ( i = 0 ; i < 16 ; i++ ) {
  474.     if ( (drv_tbl[i] = tmp[0x30 + i * 2]) == IS_NON && drvsts(i) == 0 )
  475.         drv_tbl[i] = IS_UNKW;
  476.     }
  477.     for ( i = 17 ; i < 26 ; i++ ) {
  478.     if ( drvsts(i) == 0 )
  479.         drv_tbl[i] = IS_UNKW;
  480.     }
  481.  
  482.     drv_tbl[2] = IS_NON;            /* C: drive delete */
  483.     drv_tbl[16] = IS_CDR;            /* Q: drive apend */
  484.     drv_tbl[17] = IS_NON;            /* R: drive delete */
  485. }
  486. void    ICON_disp(int x,int y,int drv)
  487. {
  488.     char tmp[8];
  489.  
  490.     DSP_rbox(x,y,x+33,y+33,XLINE_COL,WIND_COL,M_PSET);
  491.     if ( drv_tbl[drv] != IS_NON ) {
  492.     DSP_putptn(ICON_ptn[drv_tbl[drv]],x+1,y+1,x+32,y+32,
  493.             CHR_COL,WIND_COL,M_PSET);
  494.     }
  495.     if ( drv <= 16 ) {
  496.     DSP_box(x+2,y+2,x+15,y+14,WIND_COL,M_PSET);
  497.     DSP_putptn(DIGIT_ptn[drv],x+2,y+2,x+15,y+14,
  498.             CHR_COL,WIND_COL,M_PSET);
  499.     } else {
  500.     DSP_rbox(x+2, y+2, x+15, y+14, CHR_COL, WIND_COL, M_PSET);
  501.     DSP_box(x+4, y+4, x+13, y+12, CHR_COL, M_PSET);
  502.     sprintf(tmp, "%c", drv + 'A');
  503.     EGB_textZoom(work, 0, 8, 8);
  504.     DSP_msg(tmp, x+5, y+5-8, 0, WIND_COL, CHR_COL, M_PSET);
  505.     EGB_textZoom(work, 0, 8, 16);
  506.     }
  507. }
  508.  
  509. /********************************************************************
  510.  
  511.     Palette Control
  512.  
  513.     0      1        2          3        4      5
  514.     0123456789012345678901234567890123456789012345678901234567890
  515. 0    ■  < 00 >  < 00 >  < 00 >    ■  < 00 >  < 00 >  < 00 >
  516. 1    ■  < 00 >  < 00 >  < 00 >    ■  < 00 >  < 00 >  < 00 >
  517. 2    ■  < 00 >  < 00 >  < 00 >    ■  < 00 >  < 00 >  < 00 >
  518. 3    ■  < 00 >  < 00 >  < 00 >    ■  < 00 >  < 00 >  < 00 >
  519. 4    ■  < 00 >  < 00 >  < 00 >    ■  < 00 >  < 00 >  < 00 >
  520. 5    ■  < 00 >  < 00 >  < 00 >    ■  < 00 >  < 00 >  < 00 >
  521. 6    ■  < 00 >  < 00 >  < 00 >    ■  < 00 >  < 00 >  < 00 >
  522. 7    ■  < 00 >  < 00 >  < 00 >    ■  < 00 >  < 00 >  < 00 >
  523.  
  524. ********************************************************************/
  525.  
  526. #define    PLT_X    80
  527. #define    PLT_Y    140
  528.  
  529. #define    PLT_X1    PLT_X-8
  530. #define    PLT_Y1    PLT_Y-40
  531. #define    PLT_X2    PLT_X+480
  532. #define    PLT_Y2    PLT_Y+192
  533.  
  534. void    PLT_node(int col)
  535. {
  536.     int     x,y;
  537.     struct {
  538.     int    cnt;
  539.     int    col;
  540.     char    b,r,g;
  541.     char    btm;
  542.     } para;
  543.     
  544.     MOS_disp(0);
  545.  
  546.     x = PLT_X + (col % 2) * 256;
  547.     y = PLT_Y + (col / 2) * 22;
  548.  
  549.     DSP_wbox(x,y,x+19,y+19,LINE_COL,col,M_PSET);
  550.  
  551.     DSP_wbox(x+32,y,x+32+11,y+19,LINE_COL,WIND_COL,M_PSET);
  552.     gputs(x+32+2,y+2,CHR_COL,WIND_COL,"<");
  553.     DSP_wbox(x+72,y,x+72+11,y+19,LINE_COL,WIND_COL,M_PSET);
  554.     gputs(x+72+2,y+2,CHR_COL,WIND_COL,">");
  555.  
  556.     DSP_wbox(x+96,y,x+96+11,y+19,LINE_COL,WIND_COL,M_PSET);
  557.     gputs(x+96+2,y+2,CHR_COL,WIND_COL,"<");
  558.     DSP_wbox(x+136,y,x+136+11,y+19,LINE_COL,WIND_COL,M_PSET);
  559.     gputs(x+136+2,y+2,CHR_COL,WIND_COL,">");
  560.  
  561.     DSP_wbox(x+160,y,x+160+11,y+19,LINE_COL,WIND_COL,M_PSET);
  562.     gputs(x+160+2,y+2,CHR_COL,WIND_COL,"<");
  563.     DSP_wbox(x+200,y,x+200+11,y+19,LINE_COL,WIND_COL,M_PSET);
  564.     gputs(x+200+2,y+2,CHR_COL,WIND_COL,">");
  565.  
  566.     gprintf(x+48+2,y+2,CHR_COL,WIND_COL,"%02d",plt_tbl[col].b);
  567.     gprintf(x+112+2,y+2,CHR_COL,WIND_COL,"%02d",plt_tbl[col].r);
  568.     gprintf(x+176+2,y+2,CHR_COL,WIND_COL,"%02d",plt_tbl[col].g);
  569.  
  570.     para.cnt = 1;
  571.     para.col = col;
  572.     para.b = plt_tbl[col].b * 16;
  573.     para.r = plt_tbl[col].r * 16;
  574.     para.g = plt_tbl[col].g * 16;
  575.     para.btm = 0;
  576.     EGB_palette(work,0,(char *)¶);
  577.  
  578.     MOS_disp(1);
  579. }
  580. void    PLT_chk(int mx,int my,int col)
  581. {
  582.     int     x,y;
  583.  
  584.     x = PLT_X + (col % 2) * 256;
  585.     y = PLT_Y + (col / 2) * 22;
  586.  
  587.     if      ( (mx >= (x+32)) && (my >= y) && 
  588.           (mx <= (x+32+11)) && (my <= (y+19)) )
  589.     plt_tbl[col].b = (plt_tbl[col].b - 1) & 0x0F;
  590.  
  591.     else if ( (mx >= (x+72)) && (my >= y) && 
  592.           (mx <= (x+72+11)) && (my <= (y+19)) )
  593.     plt_tbl[col].b = (plt_tbl[col].b + 1) & 0x0F;
  594.  
  595.     else if ( (mx >= (x+96)) && (my >= y) && 
  596.           (mx <= (x+96+11)) && (my <= (y+19)) )
  597.     plt_tbl[col].r = (plt_tbl[col].r - 1) & 0x0F;
  598.  
  599.     else if ( (mx >= (x+136)) && (my >= y) && 
  600.           (mx <= (x+136+11)) && (my <= (y+19)) )
  601.     plt_tbl[col].r = (plt_tbl[col].r + 1) & 0x0F;
  602.  
  603.     else if ( (mx >= (x+160)) && (my >= y) && 
  604.           (mx <= (x+160+11)) && (my <= (y+19)) )
  605.     plt_tbl[col].g = (plt_tbl[col].g - 1) & 0x0F;
  606.  
  607.     else if ( (mx >= (x+200)) && (my >= y) && 
  608.           (mx <= (x+200+11)) && (my <= (y+19)) )
  609.     plt_tbl[col].g = (plt_tbl[col].g + 1) & 0x0F;
  610.  
  611.     else
  612.     return;
  613.  
  614.     PLT_node(col);
  615. }
  616. void    PLT_control(void)
  617. {
  618.     int     n,i;
  619.     int     x,y,sw;
  620.     BLOCK   *vp;
  621.  
  622.     MOS_disp(0);
  623.     vp = DSP_push_vram(PLT_X1,PLT_Y1,PLT_X2,PLT_Y2);
  624.     DSP_opbox(PLT_X1,PLT_Y1,PLT_X2,PLT_Y2);
  625. /****
  626.     DSP_wbox(PLT_X1,PLT_Y1,PLT_X2,PLT_Y2,LINE_COL,WIND_COL,M_PSET);
  627. *****/
  628.     DSP_wbox(PLT_X1+8,PLT_Y1+8,PLT_X1+38,PLT_Y1+27,LINE_COL,WIND_COL,M_PSET);
  629.     gputs(PLT_X1+10,PLT_Y1+10,CHR_COL,WIND_COL,"END");
  630.     MOS_disp(1);
  631.  
  632.     for ( i = 0 ; i < 16 ; i++ )
  633.     PLT_node(i);
  634.  
  635.     for ( ; ; ) {
  636.     MOS_rdpos(&sw,&x,&y);
  637.  
  638.     if ( (sw == 0)    ||
  639.          (x < PLT_X1) || (y < PLT_Y1) ||
  640.          (x > PLT_X2) || (y > PLT_Y2) )
  641.         continue;
  642.  
  643.     else if ( (x >= (PLT_X1+8))  && (y >= (PLT_Y1+8)) &&
  644.               (x <= (PLT_X1+38)) && (y <= (PLT_Y1+27)) )
  645.         break;
  646.  
  647.     else {
  648.         for ( i = 0 ; i < 16 ; i++ )
  649.             PLT_chk(x,y,i);
  650.     }
  651.  
  652.     do {
  653.         MOS_rdpos(&sw,&x,&y);
  654.     } while ( sw != 0 );
  655.     }
  656.  
  657.     MOS_disp(0);
  658.     DSP_pop_vram(vp);
  659.     MOS_disp(1);
  660. }
  661.  
  662. /****************************************************
  663.  
  664.     TIFF Graphic Display and SND or EUP Play
  665.  
  666. *****************************************************/
  667. char    *getins(env,file)
  668. char    *env,*file;
  669. {
  670.     static char tmp[128];
  671.     char *p;
  672.  
  673.     if ( (p = getenv(env)) == NULL )
  674.     return NULL;
  675.     sprintf(tmp,"%s\\%s",p,file);
  676.     return tmp;
  677. }
  678. char    *xopen(char *file)
  679. {
  680.     FILE    *fp;
  681.     long    fsz;
  682.     char    *buf;
  683.  
  684.     DSP_mos(2);
  685.     if( (fp = fopen(file,"rb")) == NULL )
  686.     return NULL;
  687.  
  688.     fseek(fp,0L,SEEK_END);
  689.     fsz = ftell(fp);
  690.     rewind(fp);
  691.  
  692.     if( (buf = (char *)malloc(fsz)) == NULL)
  693.     goto ERROR;
  694.  
  695.     fread(buf,fsz,1,fp);
  696.  
  697. ERROR:
  698.     fclose(fp);
  699.     DSP_mos(0);
  700.     return buf;
  701. }
  702. void    xclose(char *buf)
  703. {
  704.     free(buf);
  705. }
  706. void    mos_wait()
  707. {
  708.     int     sw,x,y;
  709.     time_t  s,e;
  710.  
  711.     time(&s);
  712.     do {
  713.     time(&e);
  714.     MOS_rdpos(&sw,&x,&y);
  715.     } while ( sw == 0 && (e - s) < 20 );
  716. }
  717.  
  718. /**************** move to tiff.c ****************
  719. void    DSP_tiff(char *file)
  720. {
  721.     int        l,n;
  722.     int     x,y;
  723.     int     len,lzw,plt;
  724.     BLOCK   para;
  725.     BLOCK   *save;
  726.     char    *buf;
  727.     short   *rp,*gp,*bp;
  728.     struct _TIF {
  729.     short    tf_tag;
  730.     short    tf_type;
  731.     int    tf_len;
  732.     int    tf_data;
  733.     } *ifd;
  734.     struct {
  735.     int    cnt;
  736.     int    col;
  737.     char    b,r,g;
  738.     char    btm;
  739.     } plpara;
  740.  
  741.     if ( (buf = xopen(file)) == NULL ) {
  742.     kakunin("TIFFファイルの読み込みに失敗しました");
  743.     return;
  744.     }
  745.  
  746.     DSP_mos(4);
  747.  
  748.     if ( buf[0] != 0x49 || buf[1] != 0x49 || buf[2] != 0x2A ) {
  749.     kakunin("このファイルはTIFF形式ではありません?");
  750.     goto ENDOF;
  751.     }
  752.  
  753.     x = y = len = plt = 0;
  754.     lzw = 1;
  755.     n = WORD(buf + DWORD(buf+4));
  756.     ifd = (struct _TIF *)(buf + DWORD(buf+4) + 2);
  757.  
  758.     while ( n-- > 0) {
  759.     if ( ifd->tf_tag == 0 )
  760.         break;
  761.     switch(ifd->tf_tag){
  762.     case 0x0100: x = ifd->tf_data; break;
  763.     case 0x0101: y = ifd->tf_data; break;
  764.     case 0x0102: len = ifd->tf_data; break;
  765.     case 0x0103: lzw = ifd->tf_data; break;
  766.     case 0x0140: plt = ifd->tf_data; break;
  767.     case 0x0111: l = ifd->tf_data; break;
  768.     }
  769.     ifd++;
  770.     }
  771.  
  772.     if ( lzw != 1 ) {
  773.     kakunin("残念ながら圧縮TIFFに対応してません");
  774.     goto ENDOF;
  775.     }
  776.     if ( len != 1 && len != 4 && len != 8 && len != 16 ) {
  777.     kakunin("対応していないピクセルモ-ドです");
  778.     goto ENDOF;
  779.     }
  780.  
  781.     para.ptn = buf + l;
  782.     para.sel = getds();
  783.     para.x1 = 0;
  784.     para.y1 = 0;
  785.     para.x2 = x-1;
  786.     para.y2 = y-1;
  787.  
  788.     MOS_disp(OFF);
  789.     save = DSP_push_vram(0,0,639,479);
  790.     EGB_displayPage(work,0,0);
  791.  
  792.     switch(len) {
  793.     case 1:
  794.         EGB_resolution(work,0,3);
  795.     EGB_writePage(work,0);
  796.     EGB_clearScreen(work);
  797.     EGB_color(work,0,15);
  798.     EGB_putBlockColor(work,0,(char *)¶);
  799.     break;
  800.  
  801.     case 4:
  802.         EGB_resolution(work,0,3);
  803.     EGB_writePage(work,0);
  804.     EGB_clearScreen(work);
  805.     EGB_putBlock(work,0,(char *)¶);
  806.     if ( plt != 0 ) {
  807.         rp = (short *)(buf + plt);
  808.         gp = (short *)(buf + plt + 32);
  809.         bp = (short *)(buf + plt + 64);
  810.         for ( n = 0 ; n < 16 ; n++ ) {
  811.         plpara.cnt = 1;
  812.         plpara.col = n;
  813.         plpara.b = *(bp++);
  814.         plpara.r = *(rp++);
  815.         plpara.g = *(gp++);
  816.         plpara.btm = 0;
  817.         EGB_palette(work,0,(char *)&plpara);
  818.         }
  819.     }
  820.     break;
  821.  
  822.     case 8:
  823.     EGB_resolution(work,0,12);
  824.     EGB_clearScreen(work);
  825.     EGB_putBlock(work,0,(char *)¶);
  826.     if ( plt != 0 ) {
  827.         rp = (short *)(buf + plt);
  828.         gp = (short *)(buf + plt + 512);
  829.         bp = (short *)(buf + plt + 1024);
  830.         for ( n = 0 ; n < 256 ; n++ ) {
  831.         plpara.cnt = 1;
  832.         plpara.col = n;
  833.         plpara.b = *(bp++);
  834.         plpara.r = *(rp++);
  835.         plpara.g = *(gp++);
  836.         plpara.btm = 0;
  837.         EGB_palette(work,0,(char *)&plpara);
  838.         }
  839.     }
  840.     break;
  841.  
  842.     case 16:
  843.         EGB_resolution(work,0,10);
  844.     EGB_writePage(work,0);
  845.     EGB_clearScreen(work);
  846.     EGB_displayStart(work,2,2,2);
  847.     EGB_displayStart(work,3,320,240);
  848.     EGB_putBlock(work,0,(char *)¶);
  849.     break;
  850.  
  851.     }
  852.  
  853.     EGB_displayPage(work,0,1);
  854.  
  855.     mos_wait();
  856.  
  857.     EGB_displayPage(work,0,0);
  858.     EGB_resolution(work,0,3);
  859.     EGB_resolution(work,1,3);
  860.     EGB_writePage(work,1);
  861.     DSP_palette();
  862.     EGB_clearScreen(work);
  863.     EGB_writePage(work,0);
  864.     DSP_palette();
  865.     EGB_clearScreen(work);
  866.     DSP_pop_vram(save);
  867.     EGB_displayPage(work,0,3);
  868.     MOS_disp(ON);
  869.  
  870. ENDOF:
  871.     xclose(buf);
  872.     DSP_mos(0);
  873. }
  874. ********************************************/
  875.  
  876. void    DSP_pxx(char *file)
  877. {
  878.     int     n;
  879.     int     objs;
  880.     int     plat;
  881.     int     mode;
  882.     long    size;
  883.     short   *sp;
  884.     char    *data;
  885.     char    *buf;
  886.     BLOCK   para;
  887.     BLOCK   *save;
  888.     struct {
  889.     int    cnt;
  890.     int    col;
  891.     char    b,r,g;
  892.     char    btm;
  893.     } plpara;
  894.  
  895.     if ( (buf = xopen(file)) == NULL ) {
  896.     kakunin("Pxxファイルの読み込みに失敗しました");
  897.     return;
  898.     }
  899.  
  900.     DSP_mos(4);
  901.  
  902.     if ( buf[0] != 0x59 || buf[1] != 0x55 || 
  903.      buf[2] != 0x4B || buf[3] != 0x49 ) {
  904.     kakunin("このファイルはPxx形式ではありません?");
  905.     goto ENDOF;
  906.     }
  907.  
  908.     objs = WORD(buf + 0x10);
  909.     mode = WORD(buf + 0x12);    /* 3 or 12 or 10 */
  910.     plat = (mode == 3 ? 96:(mode == 12 ? 1536:448));
  911.     data = buf + 0x18 + plat;
  912.  
  913.     if ( mode != 3 && mode != 12 && mode != 10 ) {
  914.     kakunin("対応していない画面モ-ドです");
  915.     goto ENDOF;
  916.     }
  917.  
  918.     MOS_disp(OFF);
  919.     if ( screen_flg == FALSE )
  920.     save = DSP_push_vram(0,0,639,479);
  921.     EGB_displayPage(work,0,0);
  922.     EGB_resolution(work,0,mode);
  923.     EGB_writePage(work,0);
  924.     EGB_clearScreen(work);
  925.     if ( mode == 10 ) {
  926.     EGB_displayStart(work,2,2,2);
  927.     EGB_displayStart(work,3,320,240);
  928.     } else {
  929.     sp = (short *)(buf + 0x18);
  930.     for ( n = 0 ; n < (plat / 6) ; n++ ) {
  931.         plpara.cnt = 1;
  932.         plpara.col = n;
  933.         plpara.r = *(sp++) >> 8;
  934.         plpara.g = *(sp++) >> 8;
  935.         plpara.b = *(sp++) >> 8;
  936.         plpara.btm = 0;
  937.         EGB_palette(work,0,(char *)&plpara);
  938.     }
  939.     }
  940.  
  941.     EGB_displayPage(work,0,1);
  942.     para.sel = getds();
  943.  
  944.     while ( objs-- > 0 ) {
  945.     if ( WORD(data) == 0 ) {    /* Haikei */
  946.         size = DWORD(data + 2);
  947.         para.x1 = WORD(data + 6);
  948.         para.y1 = WORD(data + 8);
  949.         para.x2 = WORD(data + 10);
  950.         para.y2 = WORD(data + 12);
  951.         para.ptn = data + 14;
  952.         EGB_putBlock(work,0,(char *)¶);
  953.         data += (14 + size);
  954.  
  955.     } else {            /* Object */
  956.         size = DWORD(data + 2) + DWORD(data + 6);
  957.         para.x1 = WORD(data + 10);
  958.         para.y1 = WORD(data + 12);
  959.         para.x2 = WORD(data + 14);
  960.         para.y2 = WORD(data + 16);
  961.         para.ptn = data + 18;
  962.         EGB_maskData(work,2,(char *)¶);
  963.         data += (18 + size);
  964.     }
  965.  
  966.     }
  967.  
  968.     mos_wait();
  969.  
  970.     EGB_displayPage(work,0,0);
  971.     EGB_resolution(work,0,3);
  972.     EGB_resolution(work,1,3);
  973.     EGB_writePage(work,1);
  974.     DSP_palette();
  975.     EGB_clearScreen(work);
  976.     EGB_writePage(work,0);
  977.     DSP_palette();
  978.     EGB_clearScreen(work);
  979.     if ( screen_flg == FALSE )
  980.     DSP_pop_vram(save);
  981.     EGB_displayPage(work,0,3);
  982.     MOS_disp(ON);
  983.  
  984. ENDOF:
  985.     xclose(buf);
  986.     DSP_mos(0);
  987.     FILE_redisp();
  988. }
  989. void    PLAY_snd(file)
  990. char    *file;
  991. {
  992.     int     sw,x,y;
  993.     char    *snd_buf;
  994.  
  995.     SND_pcm_sound_delete(-1);
  996.     SND_pcm_mode_set(1);
  997.  
  998.     if ( (snd_buf = xopen(file)) == NULL ) {
  999.     kakunin("SNDファイルの読み込みに失敗しました");
  1000.     return;
  1001.     }
  1002.  
  1003.     DSP_mos(3);
  1004.     SND_pan_set(71,64);
  1005.     *(int *)(snd_buf+20) = 0;
  1006.     SND_pcm_play(71,snd_buf[28],127,snd_buf);
  1007.  
  1008.     while ( SND_pcm_status(71) ) {
  1009.     MOS_rdpos(&sw,&x,&y);
  1010.     if ( sw != 0 )
  1011.         break;
  1012.     }
  1013.  
  1014.     SND_pcm_play_stop(71);
  1015.     SND_pcm_rec_stop();
  1016.     xclose(snd_buf);
  1017.     DSP_mos(0);
  1018. }
  1019. void    END_eup()
  1020. {
  1021.     if ( eup_buf == NULL )
  1022.     return;
  1023.     SND_eup_play_stop();
  1024.     xclose(eup_buf);
  1025.     eup_buf = NULL;
  1026.     DSP_mos(0);
  1027. }
  1028. void    PLAY_eup(int md, char *file)
  1029. {
  1030.     int     i;
  1031.     int     sw,x,y;
  1032.     int     err,size,signa,tempo;
  1033.     char    *p;
  1034.     char    tmp[16];
  1035.     char    dmy[16];
  1036.     char    wrk[80];
  1037.  
  1038.     END_eup();
  1039.     if( (eup_buf = xopen(file)) == NULL ) {
  1040.     kakunin("EUPファイルの読み込みに失敗しました");
  1041.     return;
  1042.     }
  1043.  
  1044.     DSP_mos(3);
  1045.  
  1046.     p = &eup_buf[852];        /* trk mute */
  1047.     for( i = 0 ; i < 32 ; i++ )
  1048.     err = SND_eup_mute_set(i,*(p++));
  1049.  
  1050.     p = &eup_buf[884];        /* trk port */
  1051.     for( i = 0 ; i < 32 ; i++ )
  1052.     err = SND_eup_port_set(i,*(p++));
  1053.  
  1054.     p = &eup_buf[916];        /* trk midi ch */
  1055.     for( i = 0 ; i < 32 ; i++ )
  1056.     err = SND_eup_midi_ch_set(i,*(p++));
  1057.  
  1058.     p = &eup_buf[948];        /* trk key bias */
  1059.     for( i = 0 ; i < 32 ; i++ )
  1060.     err = SND_eup_bias_set(i,*(p++));
  1061.  
  1062.     p = &eup_buf[980];        /* trk transpose */
  1063.     for( i = 0 ; i < 32 ; i++ )
  1064.     err = SND_eup_transpose_set(i,*(p++));
  1065.  
  1066. /********************
  1067.     channel assign
  1068. *********************/
  1069.  
  1070.     p = &eup_buf[1748];        /* fm midi ch */
  1071.     for( i = 0 ; i < 6 ; i++ )
  1072.     err = SND_midi_ch_assign(i,*(p++));
  1073.  
  1074.     p = &eup_buf[1754];        /* pcm midi ch */
  1075.     for( i = 0 ; i < 8 ; i++ )
  1076.     err = SND_midi_ch_assign(i+64,*(p++));
  1077.  
  1078. /****************
  1079.     bank load
  1080. *****************/
  1081.  
  1082.     SND_pcm_mode_set(0);
  1083.  
  1084.     strncpy(tmp,&eup_buf[1762],8);    /* fm file name */
  1085.     tmp[8] = '\0';
  1086.     if ( tmp[0] != '\0' ) {
  1087.     strcat(tmp,".FMB");
  1088.     strcpy(wrk,file);
  1089.     if ( (p = strrchr(wrk,'\\')) != NULL ) {
  1090.         strcpy(p+1,tmp);
  1091.         p = wrk;
  1092.     } else
  1093.         p = tmp;
  1094.     p = tmp;
  1095.         if ( SND_fm_bank_load(p,dmy) != 0 ) {
  1096.         if ( (p = getins("FMINST",tmp)) == NULL ||
  1097.          SND_fm_bank_load(p,dmy) != 0 )
  1098.         kakunin("%sファイルが見当たりません",tmp);
  1099.     }
  1100.     }
  1101.  
  1102.     strncpy(tmp,&eup_buf[1770],8);    /* pcm file name */
  1103.     tmp[8] = '\0';
  1104.     if ( tmp[0] != '\0' ) {
  1105.     strcat(tmp,".PMB");
  1106.     strcpy(wrk,file);
  1107.     if ( (p = strrchr(wrk,'\\')) != NULL ) {
  1108.         strcpy(p+1,tmp);
  1109.         p = wrk;
  1110.     } else
  1111.         p = tmp;
  1112.     p = tmp;
  1113.         if ( SND_pcm_bank_load(p,dmy) != 0 ) {
  1114.         if ( (p = getins("PCMINST",tmp)) == NULL ||
  1115.          SND_pcm_bank_load(p,dmy) != 0 )
  1116.         kakunin("%sファイルが見当たりません",tmp);
  1117.     }
  1118.     }
  1119.  
  1120. /*******************
  1121.     play eup file
  1122. ********************/
  1123.  
  1124.     p = &eup_buf[2048];        /* data top */
  1125.     size = *((int *)p); p += 4;
  1126.     signa = *(p++);
  1127.     tempo = *(p++);
  1128.  
  1129.     SND_eup_loop_set(0);
  1130.     SND_eup_tempo_set(tempo);
  1131.     SND_eup_play_start(p,size,signa);
  1132.  
  1133.     if ( md != FALSE )
  1134.     goto ENDOF;
  1135.  
  1136.     EUP_open();
  1137.  
  1138.     while ( SND_eup_stat_flag() ) {
  1139.     EUP_chk(SND_eup_stat_ptr());
  1140.     MOS_rdpos(&sw,&x,&y);
  1141.     if ( sw != 0 )
  1142.         break;
  1143.     }
  1144.  
  1145.     EUP_close();
  1146.  
  1147.     SND_eup_play_stop();
  1148.     xclose(eup_buf);
  1149.     eup_buf = NULL;
  1150. ENDOF:
  1151.     DSP_mos(0);
  1152. }
  1153. int    strhcmp(char *s, char *p)
  1154. {
  1155.     while ( *s != '\0' ) {
  1156.     if ( toupper(*s) != toupper(*p) )
  1157.         return (-1);
  1158.     s++;
  1159.     p++;
  1160.     }
  1161.     return (*p == '\0' ? 0:1);
  1162. }
  1163. int    JOKE_run(char *file, int sw)
  1164. {
  1165.     char    *p;
  1166.     DIR     *dirp;
  1167.     DIRECT  *dp;
  1168.     char    tmp[128];
  1169.  
  1170.     if ( strchr(file,'*') != NULL ||
  1171.      strchr(file,'?') != NULL ) {
  1172.     strcpy(tmp,file);
  1173.     if ( (p = strrchr(tmp,'\\')) != NULL ||
  1174.          (p = strrchr(tmp,':'))  != NULL )
  1175.         p++;
  1176.     else
  1177.         p = tmp;
  1178.     if ( (dirp = opendir(file)) == NULL )
  1179.         return FALSE;
  1180.     while ( (dp = readdir(dirp)) != NULL && !IS_DIR(dp) ) {
  1181.         strcpy(p,dp->d_name);        
  1182.         JOKE_run(tmp, sw);
  1183.     }
  1184.     closedir(dirp);
  1185.     return TRUE;
  1186.     }
  1187.  
  1188.     if ( (p = strrchr(file,'\\')) == NULL )
  1189.     p = file;
  1190.     if ( (p = strrchr(p,'.')) == NULL )
  1191.     return FALSE;
  1192.  
  1193.     if ( strhcmp(p,".TIF") == 0 )
  1194.     TIFF_disp(file);
  1195.     else if ( strhcmp(p,".P16") == 0 ||
  1196.           strhcmp(p,".P25") == 0 ||
  1197.           strhcmp(p,".P32") == 0 )
  1198.     DSP_pxx(file);
  1199.     else if ( strhcmp(p,".SND") == 0 )
  1200.     PLAY_snd(file);
  1201.     else if ( strhcmp(p,".EUP") == 0 )
  1202.     PLAY_eup(FALSE,file);
  1203.     else if ( strhcmp(p,".MID") == 0 )
  1204.     PLAY_midi(file);
  1205.     else if ( strhcmp(p,".QQQ") == 0 )
  1206.     CMDS_file(file);
  1207.     else if ( sw == FALSE || !PROG_command(file) )
  1208.     return FALSE;
  1209.  
  1210.     return TRUE;
  1211. }
  1212. void    SCRN_saver(int sw)
  1213. {
  1214.     static BLOCK *sv_pa = NULL;
  1215.  
  1216.     if ( sw != 0 ) {
  1217.     if ( sv_pa == NULL )
  1218.         free(sv_pa);
  1219.     MOS_disp(OFF);
  1220.     if ( (sv_pa = DSP_push_vram(0,0,639,479)) != NULL )
  1221.         screen_flg = TRUE;
  1222.     MOS_disp(ON);
  1223.     } else {
  1224.     MOS_disp(OFF);
  1225.     DSP_pop_vram(sv_pa);
  1226.     MOS_disp(ON);
  1227.     sv_pa = NULL;
  1228.     screen_flg = FALSE;
  1229.     }
  1230. }
  1231.